<?php
    include_once('php/getrecentdocuments.php'); 
?>

<div id="SE_header"> 
<div id="toppanel">
	<div id="panel">
		<div class="content clearfix">
			<div class="left">
				<h1>simPL Editor</h1>
				<h2>An editor for simPL</h2>		
				<p class="grey">A simple editor for a simple language, everything can be done from this web app.</p>
				<h2>Questions/Comments</h2>
				<p class="grey">Feel free to contact us at <a>placeholder</a></p>
			</div>
            
            
            <?php
			
			if(!$_SESSION['id']):
			
			?>
            
			<div class="left">
				<!-- Login Form -->
				<form class="clearfix" action="" method="post">
					<h1>Member Login</h1>
                    
                    <?php
						
						if($_SESSION['msg']['login-err'])
						{
							echo '<div class="err">'.$_SESSION['msg']['login-err'].'</div>';
							unset($_SESSION['msg']['login-err']);
						}
					?>
					
					<label class="grey" for="username">Username:</label>
					<input class="field" type="text" name="username" id="username" value="" size="23" />
					<label class="grey" for="password">Password:</label>
					<input class="field" type="password" name="password" id="password" size="23" />
	            	<label><input name="rememberMe" id="rememberMe" type="checkbox" checked="checked" value="1" /> &nbsp;Remember me</label>
        			<div class="clear"></div>
					<input type="submit" name="submit" value="Login" class="bt_login" />
				</form>
			</div>
			<div class="left right register">			
				<!-- Register Form -->
			  <h1>Not a member? Sign Up!</h1>		
	                  <h2>Signing up is free and easy!</h2>		
			  <p class="grey">Simply click the login registration below to start building simPL applications!</p>
                          <button id="registerButton" class="bt_register">Register</button>
                          <div id="dialogRegister" title="Registration Form">
		   	  <form action="" method="post">
                               <?php
						
						if($_SESSION['msg']['reg-err'])
						{
							echo '<div class="err">'.$_SESSION['msg']['reg-err'].'</div>';
							unset($_SESSION['msg']['reg-err']);
						}
						
						if($_SESSION['msg']['reg-success'])
						{
							echo '<div class="success">'.$_SESSION['msg']['reg-success'].'</div>';
							unset($_SESSION['msg']['reg-success']);
						}
			       ?>
                    		
			       <label class="grey" for="first_name">First Name:</label>
			       <input class="field" type="text" name="first_name" id="first_name" value="" size="23" />
			       <label class="grey" for="last_name">Last Name:</label>
			       <input class="field" type="text" name="last_name" id="last_name" value="" size="23" />
			       <label class="grey" for="username">Username:</label>
			       <input class="field" type="text" name="username" id="username" value="" size="23" />
			       <label class="grey" for="email">Email:</label>
			       <input class="field" type="text" name="email" id="email" size="23" />
			       <label class="grey" for="password">Password:</label>
			       <input class="field" type="password" name="password" id="password" size="23" />
			       <input type="submit" name="submit" value="Register" class="bt_register" />
			   </form>
                          </div>
		        </div>
            
            <?php
			
			else:
			
			?>
            
            <div class="left">
            
            <h1>Members panel</h1>
            
            <p>Recently edited projects:</p>
            <?php 
                echo $recentDocuments; 
            ?>
            <p>- or -</p>
            <a href="?logoff">Log off</a>
            
            </div>
            
            <div class="left right">
            </div>
            
            <?php
			endif;
			?>
		</div>
	</div> <!-- /login -->	

    <!-- The tab on top -->	
	<div class="tab">
		<ul class="login">
	    	<li class="left">&nbsp;</li>
	        <li>Hello <?php echo $_SESSION['user'] ? $_SESSION['user'] : 'Guest';?>!</li>
			<li class="sep">|</li>
			<li id="toggle">
				<a id="open" class="open" href="#"><?php echo $_SESSION['id']?'Open Panel':'Log In | Register';?></a>
				<a id="close" style="display: none;" class="close" href="#">Close Panel</a>			
			</li>
	    	<li class="right">&nbsp;</li>
		</ul> 
	</div> <!-- / top -->
	
</div> <!--panel -->
</div>
